package com.spark.lola.rpc;

import com.spark.lola.feign.LogisticsBiFeignService;
import com.spark.lola.mapper.statistics.StatisticsDriverMapper;
import com.spark.lola.mapper.statistics.StatisticsLogisticsMapper;
import com.spark.lola.statistics.dto.FindLogisticsDto;
import com.spark.lola.statistics.entity.StatisticsDriver;
import com.spark.lola.statistics.entity.StatisticsLogistics;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: Zhi-peng wang
 * @date: 2020/05/20 06:15
 **/
@RestController
@RequestMapping(value = "/rpc/logistics", produces = "application/json;charset=UTF-8")
public class LogisticsBiFeignServiceImpl implements LogisticsBiFeignService {

    @Autowired
    private StatisticsLogisticsMapper statisticsLogisticsMapper;

    @Autowired
    private StatisticsDriverMapper statisticsDriverMapper;

    @Override
    @RequestMapping(value = "/statistics/all", method = RequestMethod.POST)
    public List<StatisticsLogistics> findStatisticsLogistics(@RequestBody FindLogisticsDto<?> findLogisticsDto) {
        return statisticsLogisticsMapper.findByFindType(findLogisticsDto);
    }

    @Override
    @RequestMapping(value = "/statistics/driver", method = RequestMethod.POST)
    public List<StatisticsDriver> findStatisticsDriver(@RequestBody FindLogisticsDto<?> findLogisticsDto) {
        return statisticsDriverMapper.findByFindType(findLogisticsDto);
    }
}
